﻿/*
 * Created by SharpDevelop.
 * User: kat
 * Date: 11/11/2011
 * Time: 7:06 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using Business_Entity;
using System.Drawing;
using System.Windows.Forms;
using Business_Entity;
using DAOFactory;

namespace Business_Logic
{
	/// <summary>.c
	/// Description of BLPrivilegio.
	/// </summary>
	public class BLPrivilegio
	{
		public BLPrivilegio()
		{
		}
		
		public List<BEPrivilegio> getPrivs (string idRol){
			return (new DAOUsuario()).getPrivilegio(idRol);
		}
		
		public Boolean existeModulo(string modulo, List<BEPrivilegio> listaPriv){
			for(int i=0;i<listaPriv.Count;i++){
				if (listaPriv[i].Modulo.Equals(modulo)){
					//MessageBox.Show("encuentra modulo: "+modulo,"Aviso");
					return true;
				}
			}
			return false;
		}
		
		public Boolean existeVentana(string modulo, string ventana, List<BEPrivilegio> listaPriv){
			for(int i=0;i<listaPriv.Count;i++){
				if (listaPriv[i].Modulo.Equals(modulo)  && listaPriv[i].Ventana.Equals(ventana)){
					//MessageBox.Show("encuentra ventana: " +ventana,"Aviso");
					return true;
				}
			}
			return false;
		}
		
		public Boolean existePrivilegio (int priv, string modulo, string ventana, List<BEPrivilegio> listaPriv){
			for(int i=0;i<listaPriv.Count;i++){
				if (listaPriv[i].Modulo.Equals(modulo) && listaPriv[i].Ventana.Equals(ventana) &&
				    listaPriv[i].IdPrivilegio==priv) {
					
					//MessageBox.Show("encuentra privilegio","Aviso");
					return true;
				}
					
			}
			return false;
		}
	}
}
